import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEAction } from './ipsdeaction';
import { IPSDEActionInput } from './ipsdeaction-input';
import { IPSDEActionLogic } from './ipsdeaction-logic';
import { IPSDEActionParam } from './ipsdeaction-param';
import { IPSDEActionReturn } from './ipsdeaction-return';
import { IPSDEActionVR } from './ipsdeaction-vr';
import { IPSDEOPPriv } from '../priv/ipsdeoppriv';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { IPSSubSysServiceAPIDEMethod } from '../../service/ipssub-sys-service-apidemethod';
import { IPSSysTestCase } from '../../testing/ipssys-test-case';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEActionImplBase extends PSModelObjectImpl implements IPSDEAction, IPSModelSortable {
  get actionHolder(): 1 | 2 | 3 {
    return this.M.actionHolder != null ? this.M.actionHolder : 3;
  }

  get actionMode(): 'CREATE' | 'READ' | 'UPDATE' | 'DELETE' | 'CUSTOM' | 'GETDRAFT' | 'UNKNOWN' | 'MOVEORDER' | 'CHECKKEY' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.actionMode;
  }

  get actionTag(): string {
    return this.M.actionTag;
  }

  get actionTag2(): string {
    return this.M.actionTag2;
  }

  get actionTag3(): string {
    return this.M.actionTag3;
  }

  get actionTag4(): string {
    return this.M.actionTag4;
  }

  get actionType(): 'USERCUSTOM' | 'DELOGIC' | 'BUILTIN' | 'SELECTBYKEY' | 'USERCREATE' | 'USERUPDATE' | 'USERSYSUPDATE' | 'SCRIPT' | 'REMOTE' {
    return this.M.actionType;
  }

  protected afterpsdeactionlogics: IPSDEActionLogic[] | null = null;

  getAfterPSDEActionLogics(): IPSDEActionLogic[] | null {
    if (this.afterpsdeactionlogics == null) {
      this.afterpsdeactionlogics = this.fillChildListModel(this.M.getAfterPSDEActionLogics, 'dataentity.action.IPSDEActionLogic') as IPSDEActionLogic[];
    }
    return this.afterpsdeactionlogics;
  }

  get afterPSDEActionLogics(): IPSDEActionLogic[] | null {
    return this.getAfterPSDEActionLogics();
  }

  findAfterPSDEActionLogic(objKey: any): IPSDEActionLogic | null {
    return this.getPSModel5('dataentity.action.IPSDEActionLogic', this.getAfterPSDEActionLogics(), objKey) as IPSDEActionLogic;
  }

  get batchActionMode(): 0 | 1 | 2 | 5 | 6 {
    return this.M.batchActionMode != null ? this.M.batchActionMode : 0;
  }

  protected beforepsdeactionlogics: IPSDEActionLogic[] | null = null;

  getBeforePSDEActionLogics(): IPSDEActionLogic[] | null {
    if (this.beforepsdeactionlogics == null) {
      this.beforepsdeactionlogics = this.fillChildListModel(this.M.getBeforePSDEActionLogics, 'dataentity.action.IPSDEActionLogic') as IPSDEActionLogic[];
    }
    return this.beforepsdeactionlogics;
  }

  get beforePSDEActionLogics(): IPSDEActionLogic[] | null {
    return this.getBeforePSDEActionLogics();
  }

  findBeforePSDEActionLogic(objKey: any): IPSDEActionLogic | null {
    return this.getPSModel5('dataentity.action.IPSDEActionLogic', this.getBeforePSDEActionLogics(), objKey) as IPSDEActionLogic;
  }

  protected checkpsdeactionlogics: IPSDEActionLogic[] | null = null;

  getCheckPSDEActionLogics(): IPSDEActionLogic[] | null {
    if (this.checkpsdeactionlogics == null) {
      this.checkpsdeactionlogics = this.fillChildListModel(this.M.getCheckPSDEActionLogics, 'dataentity.action.IPSDEActionLogic') as IPSDEActionLogic[];
    }
    return this.checkpsdeactionlogics;
  }

  get checkPSDEActionLogics(): IPSDEActionLogic[] | null {
    return this.getCheckPSDEActionLogics();
  }

  findCheckPSDEActionLogic(objKey: any): IPSDEActionLogic | null {
    return this.getPSModel5('dataentity.action.IPSDEActionLogic', this.getCheckPSDEActionLogics(), objKey) as IPSDEActionLogic;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  get pOTime(): number {
    return this.M.pOTime != null ? this.M.pOTime : -1;
  }

  protected psdeactioninput: IPSDEActionInput | null = null;

  getPSDEActionInput(): IPSDEActionInput | null {
    if (this.psdeactioninput != null) return this.psdeactioninput;
    const value = this.M.getPSDEActionInput;
    if (value == null) {
      return null;
    }
    this.psdeactioninput = this.getPSModel4('dataentity.action.IPSDEActionInput', value, 'getPSDEActionInput') as IPSDEActionInput;
    return this.psdeactioninput;
  }

  get psDEActionInput(): IPSDEActionInput | null {
    return this.getPSDEActionInput();
  }

  getPSDEActionInputMust(): IPSDEActionInput {
    const value = this.getPSDEActionInput();
    if (value == null) {
      throw new Error('未指定调用输入对象');
    }
    return value;
  }

  protected psdeactionparams: IPSDEActionParam[] | null = null;

  getPSDEActionParams(): IPSDEActionParam[] | null {
    if (this.psdeactionparams == null) {
      this.psdeactionparams = this.fillChildListModel(this.M.getPSDEActionParams, 'dataentity.action.IPSDEActionParam') as IPSDEActionParam[];
    }
    return this.psdeactionparams;
  }

  get psDEActionParams(): IPSDEActionParam[] | null {
    return this.getPSDEActionParams();
  }

  findPSDEActionParam(objKey: any): IPSDEActionParam | null {
    return this.getPSModel5('dataentity.action.IPSDEActionParam', this.getPSDEActionParams(), objKey) as IPSDEActionParam;
  }

  protected psdeactionreturn: IPSDEActionReturn | null = null;

  getPSDEActionReturn(): IPSDEActionReturn | null {
    if (this.psdeactionreturn != null) return this.psdeactionreturn;
    const value = this.M.getPSDEActionReturn;
    if (value == null) {
      return null;
    }
    this.psdeactionreturn = this.getPSModel4('dataentity.action.IPSDEActionReturn', value, 'getPSDEActionReturn') as IPSDEActionReturn;
    return this.psdeactionreturn;
  }

  get psDEActionReturn(): IPSDEActionReturn | null {
    return this.getPSDEActionReturn();
  }

  getPSDEActionReturnMust(): IPSDEActionReturn {
    const value = this.getPSDEActionReturn();
    if (value == null) {
      throw new Error('未指定调用返回对象');
    }
    return value;
  }

  protected psdeactionvrs: IPSDEActionVR[] | null = null;

  getPSDEActionVRs(): IPSDEActionVR[] | null {
    if (this.psdeactionvrs == null) {
      this.psdeactionvrs = this.fillChildListModel(this.M.getPSDEActionVRs, 'dataentity.action.IPSDEActionVR') as IPSDEActionVR[];
    }
    return this.psdeactionvrs;
  }

  get psDEActionVRs(): IPSDEActionVR[] | null {
    return this.getPSDEActionVRs();
  }

  findPSDEActionVR(objKey: any): IPSDEActionVR | null {
    return this.getPSModel5('dataentity.action.IPSDEActionVR', this.getPSDEActionVRs(), objKey) as IPSDEActionVR;
  }

  protected psdeoppriv: IPSDEOPPriv | null = null;

  getPSDEOPPriv(): IPSDEOPPriv | null {
    if (this.psdeoppriv != null) return this.psdeoppriv;
    const value = this.M.getPSDEOPPriv;
    if (value == null) {
      return null;
    }
    this.psdeoppriv = this.getPSModel4('dataentity.priv.IPSDEOPPriv', value, 'getPSDEOPPriv') as IPSDEOPPriv;
    return this.psdeoppriv;
  }

  get psDEOPPriv(): IPSDEOPPriv | null {
    return this.getPSDEOPPriv();
  }

  getPSDEOPPrivMust(): IPSDEOPPriv {
    const value = this.getPSDEOPPriv();
    if (value == null) {
      throw new Error('未指定服务访问操作标识');
    }
    return value;
  }

  protected pssubsysserviceapidemethod: IPSSubSysServiceAPIDEMethod | null = null;

  getPSSubSysServiceAPIDEMethod(): IPSSubSysServiceAPIDEMethod | null {
    if (this.pssubsysserviceapidemethod != null) return this.pssubsysserviceapidemethod;
    const value = this.M.getPSSubSysServiceAPIDEMethod;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.pssubsysserviceapidemethod = ipsdataentity.getPSSubSysServiceAPIDEMust().findPSSubSysServiceAPIDEMethod(value);
    }
    return this.pssubsysserviceapidemethod;
  }

  get psSubSysServiceAPIDEMethod(): IPSSubSysServiceAPIDEMethod | null {
    return this.getPSSubSysServiceAPIDEMethod();
  }

  getPSSubSysServiceAPIDEMethodMust(): IPSSubSysServiceAPIDEMethod {
    const value = this.getPSSubSysServiceAPIDEMethod();
    if (value == null) {
      throw new Error('未指定外部服务接口方法');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  protected pssystestcases: IPSSysTestCase[] | null = null;

  getPSSysTestCases(): IPSSysTestCase[] | null {
    if (this.pssystestcases == null) {
      this.pssystestcases = this.fillChildListModel(this.M.getPSSysTestCases, 'testing.IPSSysTestCase') as IPSSysTestCase[];
    }
    return this.pssystestcases;
  }

  get psSysTestCases(): IPSSysTestCase[] | null {
    return this.getPSSysTestCases();
  }

  findPSSysTestCase(objKey: any): IPSSysTestCase | null {
    return this.getPSModel5('testing.IPSSysTestCase', this.getPSSysTestCases(), objKey) as IPSSysTestCase;
  }

  get paramMode(): 1 | 2 | 3 {
    return this.M.paramMode != null ? this.M.paramMode : 1;
  }

  protected preparepsdeactionlogics: IPSDEActionLogic[] | null = null;

  getPreparePSDEActionLogics(): IPSDEActionLogic[] | null {
    if (this.preparepsdeactionlogics == null) {
      this.preparepsdeactionlogics = this.fillChildListModel(this.M.getPreparePSDEActionLogics, 'dataentity.action.IPSDEActionLogic') as IPSDEActionLogic[];
    }
    return this.preparepsdeactionlogics;
  }

  get preparePSDEActionLogics(): IPSDEActionLogic[] | null {
    return this.getPreparePSDEActionLogics();
  }

  findPreparePSDEActionLogic(objKey: any): IPSDEActionLogic | null {
    return this.getPSModel5('dataentity.action.IPSDEActionLogic', this.getPreparePSDEActionLogics(), objKey) as IPSDEActionLogic;
  }

  protected realpsdeaction: IPSDEAction | null = null;

  getRealPSDEAction(): IPSDEAction | null {
    if (this.realpsdeaction != null) return this.realpsdeaction;
    const value = this.M.getRealPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.realpsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.realpsdeaction;
  }

  get realPSDEAction(): IPSDEAction | null {
    return this.getRealPSDEAction();
  }

  getRealPSDEActionMust(): IPSDEAction {
    const value = this.getRealPSDEAction();
    if (value == null) {
      throw new Error('未指定实际执行行为');
    }
    return value;
  }

  get tempDataMode(): 0 | 1 | 2 {
    return this.M.tempDataMode != null ? this.M.tempDataMode : 0;
  }

  get testActionMode(): 0 | 1 | 3 {
    return this.M.testActionMode != null ? this.M.testActionMode : 0;
  }

  get timeOut(): number {
    return this.M.timeOut != null ? this.M.timeOut : -1;
  }

  get transactionMode(): 'DEFAULT' | 'REQUIRED' | 'MANDATORY' | 'NESTED' | 'REQUIRES_NEW' | 'NOT_SUPPORTED' | 'SUPPORTS' | 'NONE' | 'GLOBAL' | 'USER' | 'USER2' {
    return this.M.transactionMode || 'DEFAULT';
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get asyncAction(): boolean {
    return this.M.asyncAction != null ? this.M.asyncAction : false;
  }

  get batchAction(): boolean {
    return this.M.batchAction != null ? this.M.batchAction : false;
  }

  get builtinAction(): boolean {
    return this.M.builtinAction != null ? this.M.builtinAction : false;
  }

  get customParam(): boolean {
    return this.M.customParam != null ? this.M.customParam : false;
  }

  get enableAudit(): boolean {
    return this.M.enableAudit != null ? this.M.enableAudit : false;
  }

  get enableBackend(): boolean {
    return this.M.enableBackend != null ? this.M.enableBackend : true;
  }

  get enableFront(): boolean {
    return this.M.enableFront != null ? this.M.enableFront : true;
  }

  get enableTempData(): boolean {
    return this.M.enableTempData != null ? this.M.enableTempData : false;
  }

  get prepareLast(): boolean {
    return this.M.prepareLast != null ? this.M.prepareLast : false;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }

  get cls(): string {
    return 'PSDEActionImplBase';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'dataentity.action.IPSDEAction') return true;
    return super.instanceof(cls);
  }
}
